﻿<template>
  <a-modal
    :title="title"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="渠道ID" prop="AID">
          <a-input v-model="entity.AID" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="渠道域名" prop="WebUrl">
          <a-input v-model="entity.WebUrl" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="渠道LOGO" prop="WebLogoUrl">
          <a-input v-model="entity.WebLogoUrl" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="系统背景URL" prop="WebBackImgUrl">
          <a-input v-model="entity.WebBackImgUrl" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="系统名称" prop="WebSystemName">
          <a-input v-model="entity.WebSystemName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="系统备案信息" prop="WebBA">
          <a-input v-model="entity.WebBA" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="状态" prop="Status">
          <a-input v-model="entity.Status" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="小程序名称" prop="AppletName">
          <a-input v-model="entity.AppletName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="小程序APPID" prop="Appletappid">
          <a-input v-model="entity.Appletappid" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="小程序APPSECRET" prop="Appletappsecret">
          <a-input v-model="entity.Appletappsecret" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="短信签名" prop="smsSignName">
          <a-input v-model="entity.smsSignName" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="系统ICO" prop="icoUrl">
          <a-input v-model="entity.icoUrl" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="系统登录LOGO" prop="LoginLogoUrl">
          <a-input v-model="entity.LoginLogoUrl" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="数据权限" prop="DataAreaId">
          <a-input v-model="entity.DataAreaId" autocomplete="off" />
        </a-form-model-item>
        <a-form-model-item label="用户类型" prop="userType">
          <a-input v-model="entity.userType" autocomplete="off" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data() {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init() {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm(id, title) {
      this.init()

      if (id) {
        this.loading = true
        this.$http.post('/Base_leasesystem_agentwebconfig/leasesystem_agentwebconfig/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit() {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/Base_leasesystem_agentwebconfig/leasesystem_agentwebconfig/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
